1. Field of the Invention
The present invention relates to compilers. More specifically, to the compilation of software during run time.
2. Description of the Related Art
The JAVA™ programming language is a general-purpose, object-oriented programming language developed by Sun Microsystems. JAVA™ is a trademark or a registered trademark of Sun Microsystems, Inc. in the United States and other countries. It is designed to provide secure delivery of software components across multiple host architectures and to be portable enough to be executed on devices ranging from personal devices (e.g., pagers, cell phones, and smart cards) to supercomputers.
To execute a program written in the Java™ programming language, the program source file is compiled and a class file, containing virtual machine instructions, is produced. The class file is then executed by a Java™ Virtual Machine (hereinafter JVM). In general, the JVM is an interpreter that decodes and executes the virtual machine instructions contained in the class file. These virtual machine instructions are referred to as bytecodes. In addition to the bytecodes, the class file includes other information utilized and/or operated on by the JVM. For example, the class file includes a number to identify the class file format and a constant pool table to identify constants that are referenced within the class file.
The Java™ programming language is an interpreted language. Generally, an interpreted language is a language in which programs are translated and executed one statement at a time. As an example, in the Java™ environment, the virtual machine instructions contained in a class file are interpreted by the JVM, translated on-the-fly into native machine code, and then executed.
A disadvantage of interpretive languages involves speed of execution. Being interpreted, the Java™ programming language can be slower than other languages implemented with compilers when each is executing the same algorithms. However, as an interpreted language, the Java™ language is able to provide a more flexible run time environment in which classes and dynamic constructs contained in the Java™ programming language can be dynamically resolved. The term “run time” refers to the time during which a program is running or executing. This is not to be confused with the term “runtime”, which refers to an engine that provides services to an application during run time. For example, the Java™ Runtime Environment (JRE) refers to the smallest set of executables and files that constitute the standard Java™ platform. The term “dynamic constructs” refers to those constructs in the Java™ programming language that allow new source code to be added to the program during execution, and to be executed on-the-fly, without user intervention. The methods ClassLoader.defineClass and Class.forName are examples of dynamic constructs utilized in the Java™ programming language. With dynamic constructs, a lexical production composed dynamically by the program is able to vary with state. Contrast this with compiled languages, which must execute from a static, generally immutable, pre-determined expression called a load module (a load module is, for example, the a.out file or .exe file seen on various platforms). Compiled languages typically lack dynamic constructs and thus lack the dynamic features provided by the Java™ programming language.
Thus, it is desirable that the Java™ programming language be compiled rather than interpreted. However, the Java™ language contains dynamic constructs at odds with the nondynamic (static) character of compiled programs. For example, because dynamic constructs can operate on information known only during run time, traditional compilation of dynamic constructs can result in an incorrect result or unexpected failure, during compilation and/or run time. Because of the challenges that exist in providing a conforming Java™ compiler which supports the dynamic nature of the Java™ language, the Java™ language has never been implemented entirely as a compiled language.
Thus, a need has been felt for a method and apparatus that allows for run time compilation of Java™ software that requires run time information.